package Service;

import Entity.Hotel;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import androidx.appcompat.app.AppCompatActivity;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

public class MyTool extends AppCompatActivity {


    public ArrayList<Hotel> Hotel_cursor_to_arraryList(Cursor cur){
        ArrayList<Hotel> coll = new ArrayList<Hotel>();
        cur.moveToFirst();  // 重中之重，千万不能忘了
        while(!cur.isAfterLast()){
            Hotel hotel=new Hotel();
             hotel.setHotelid(Integer.parseInt(cur.getString(0)));
             hotel.setHotelname(cur.getString(1));
             hotel.setStar(cur.getString(2));
             hotel.setLogo(cur.getString(3));
             hotel.setCity(cur.getString(4));
             hotel.setPhone(cur.getString(5));
             hotel.setIntroduce(cur.getString(6));
             hotel.setAddr(cur.getString(7));
            coll.add(hotel);
            cur.moveToNext();
    }
        return coll;
    }

    public int  getResourceId(String imageName){
        Context ctx=getBaseContext();
        int resId = getResources().getIdentifier(imageName, "drawable" , ctx.getPackageName());
        return resId;
    }
}
